<?php

namespace App\Http\Controllers\Api;

use App\Services\Api\ApiService;
use App\Services\PermissionRoleService;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class PermissionRoleController extends Controller
{
    private $service;

    public function __construct(ApiService $apiService, PermissionRoleService $service)
    {
        parent::__construct($apiService);
        $this->service = $service;
    }

    /**
     * @param $role_id
     * @return mixed
     */
    public function show($role_id)
    {
        $data = $this->service->repository->scopeQuery(function ($query){
            return $query->with('permission');
        })->findWhere(['role_id' => $role_id]);
        return $this->apiService->run(200, $data);
    }
}
